package io.bloom.cloud.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;


// https://www.jianshu.com/p/59930f55ffbd
@SpringBootApplication
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	//Consumer接口
	@FeignClient(name = "elements", fallback = ConsumerFallback.class)
	public interface Consumer {
		@RequestMapping(value = "/index")
		String index();
	}

	//ConsumerFallback类，实现Consumer接口
	@Component
	public static class ConsumerFallback implements Consumer {
		@Override
		public String index() {
			return "eureka feign客户端访问失败";
		}
	}

// 	//测试类，注入这个bean，即可调用
// @RestController
// public class test
// {
//    @Autowired
//    Consumer consumer;

//    @RequestMapping(value = "/test", method = RequestMethod.GET)
//    public String testeureka()
//    {
//         return  consumer.index();
//    }
// }
}
